import * as types from '../mutation-types'

const state = {
    device: {
        isMobile: false,
        isTablet: false
    },
    header: {
        hidden: true
    },
    sidebar: {
        opened: false,
        hidden: false
    },
    effect: {
        translate3d: true
    },
    tabbar:{
        active:'my'
    }
};

const mutations = {
    [types.TOGGLE_DEVICE] (state, device) {
        state.device.isMobile = device === 'mobile';
        state.device.isTablet = device === 'tablet'
    },

    [types.TOGGLE_SIDEBAR] (state, opened) {
        if (state.device.isMobile) {
            state.sidebar.opened = opened
        } else {
            state.sidebar.opened = true
        }
    },

    [types.SWITCH_EFFECT] (state, effectItem) {
        for (let name in effectItem) {
            state.effect[name] = effectItem[name]
        }
    }
}

export default {
    state,
    mutations
}
